//
//  DYShopDecorateVC.m
//  kafuMerchant
//
//  Created by 帝云科技 on 2018/9/20.
//  Copyright © 2018年 帝云科技. All rights reserved.
//

#import "DYShopDecorateVC.h"
#import "DYAddBranchShopCell.h"
#import "DYShopDecorateCell.h"
#import "DYShopDecorateInputInfoCell.h"

@interface DYShopDecorateVC ()

@property (nonatomic,strong)NSArray *titleArray;
@property (nonatomic,strong)NSArray *palceholderArray;

@property (nonatomic,strong)UIButton *submitButton;
@property (nonatomic,strong)UIView *footerView;

@property (nonatomic,strong)NSMutableArray *shopLogoArray;
@property (nonatomic,strong)NSMutableArray *shopShowArray;
@property (nonatomic,strong)NSMutableArray *shopInteriorArray;


@end

@implementation DYShopDecorateVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title=@"商铺装修";
}
-(void)dy_initData
{
    [super dy_initData];
    
    self.shopLogoArray=[NSMutableArray array];
    self.shopShowArray=[NSMutableArray array];
    self.shopInteriorArray=[NSMutableArray array];
    
    self.titleArray=@[@"店铺名称",@"店铺标志",@"店铺全称",@"行业",@"店铺地址",@"详细地址",@"店铺电话",@"营业时间",@"店铺标语",@"店铺简介",@"门头展示（1-5张）",@"排列方式",@"内景展示（1-10张）",@"排列方式"];
    self.palceholderArray=@[@"请输入店铺名称",@"",@"请输入店铺全称",@"请选择行业",@"请选择店铺地址",@"请输入店铺详细地址",@"请输入店铺电话",@"示例：9:00-18:00",@"请输入店铺标语",@"请输入店铺简介",@"",@"",@"",@""];
}
-(void)dy_initUI
{
    [super dy_initUI];
    
    self.tableView.backgroundColor=WhiteColor;
    
    [self.tableView registerClass:[DYAddBranchShopCell class] forCellReuseIdentifier:@"DYAddBranchShopCell"];
    [self.tableView registerClass:[DYShopDecorateCell class] forCellReuseIdentifier:@"DYShopDecorateCell"];
    [self.tableView registerClass:[DYShopDecorateSeletedCell class] forCellReuseIdentifier:@"DYShopDecorateSeletedCell"];
    [self.tableView registerClass:[DYShopDecorateInputInfoCell class] forCellReuseIdentifier:@"DYShopDecorateInputInfoCell"];
    
    self.tableView.showsVerticalScrollIndicator=NO;
    self.tableView.tableFooterView=self.footerView;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 14;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row==1||indexPath.row==10) {
        return BILIHEIGHT(100);
    }else if (indexPath.row==11||indexPath.row==13){
        return BILIHEIGHT(60);
    }else  if (indexPath.row==12) {
        if (self.shopInteriorArray.count>=5) {
            return BILIHEIGHT(180);
        }
        return BILIHEIGHT(100);
    }else if (indexPath.row==9){
        return BILIHEIGHT(180);
    }
    return BILIHEIGHT(58);
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (indexPath.row==1||indexPath.row==10||indexPath.row==12) {
        DYShopDecorateCell *cell=[tableView dequeueReusableCellWithIdentifier:[NSString stringWithFormat:@"DYShopDecorateCell%ld",(long)indexPath.row]];
        if (!cell) {
            cell=[[DYShopDecorateCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[NSString stringWithFormat:@"DYShopDecorateCell%ld",(long)indexPath.row]];
        }
        cell.titleLabel.text=self.titleArray[indexPath.row];
        if (indexPath.row==1) {
            cell.imageNumber=1;
             cell.hideSeparatorLabel=NO;
            cell.dataArray=self.shopLogoArray;
        }else if(indexPath.row==10){
            cell.imageNumber=5;
             cell.hideSeparatorLabel=YES;
            cell.dataArray=self.shopShowArray;
        }else{
            cell.imageNumber=10;
            cell.dataArray=self.shopInteriorArray;
            cell.hideSeparatorLabel=YES;
        }
        @weakify(self);
        cell.imageBlock = ^(NSMutableArray *imageArray) {
            @strongify(self);
            if (indexPath.row==1) {
                self.shopLogoArray=imageArray;
            }else if (indexPath.row==10){
                self.shopShowArray=imageArray;
            }else{
                self.shopInteriorArray=imageArray;
            }
             [self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:indexPath.row inSection:0]] withRowAnimation:UITableViewRowAnimationFade];
        };
        
        return cell;
    }else if (indexPath.row==11||indexPath.row==13){
        DYShopDecorateSeletedCell *cell=[tableView dequeueReusableCellWithIdentifier:@"DYShopDecorateSeletedCell" forIndexPath:indexPath];
        return cell;
    }else if (indexPath.row==9){
        DYShopDecorateInputInfoCell *cell=[tableView dequeueReusableCellWithIdentifier:@"DYShopDecorateInputInfoCell" forIndexPath:indexPath];
        return cell;
    }
    DYAddBranchShopCell *cell=[tableView dequeueReusableCellWithIdentifier:@"DYAddBranchShopCell" forIndexPath:indexPath];
    
    cell.titleLabel.text=self.titleArray[indexPath.row];
    cell.textField.placeholder=self.palceholderArray[indexPath.row];
    [cell.textField setValue:[UIColor xhq_assist] forKeyPath:@"_placeholderLabel.textColor"];
    if (indexPath.row==3||indexPath.row==4) {
        cell.arrowImageView.hidden=NO;
        cell.textField.enabled=NO;
    }else{
        cell.arrowImageView.hidden=YES;
        cell.textField.enabled=YES;
        if (indexPath.row==6) {
            [cell.textField setNumbersKeyboard];
        }
    }
    cell.textFieldBlock = ^(NSString *text) {
        NSLog(@"%@",text);
    };
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row==4) {
        XHQHUDTEXT(@"选择员工权限");
    }
}
-(void)submitButtonClick
{
    
}
-(UIView *)footerView
{
    if (!_footerView) {
        _footerView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, BILIHEIGHT(78))];
        [_footerView addSubview:self.submitButton];
    }
    return _footerView;
}
-(UIButton *)submitButton
{
    if (!_submitButton) {
        _submitButton=[Utils createBtnWithType:UIButtonTypeCustom backgroundColor:[UIColor xhq_base] action:@selector(submitButtonClick) target:self title:@"保存装修" image:@"icon_login" font:17 textColor:WhiteColor];
        _submitButton.frame=CGRectMake(kScreenWidth-BILIWIDTH(142),BILIHEIGHT(10), BILIWIDTH(132), BILIHEIGHT(38));
        [_submitButton placeImageTitlePosition: ZYButtonImagePositionRight space:BILIWIDTH(10)];
        [_submitButton xhq_cornerRadius:BILIHEIGHT(19)];
    }
    return _submitButton;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
